<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        {{testData}}
    </div>
    <script src="../assets/vue2.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data() {
                return {
                    testData: '初始化数据', // 初始化
                }
            },
            beforeCreate() { console.log('beforeCreate'); },
            // 【常用】组件实例已创建，尚未挂载，dom不存在
            created() { console.log('created ' + this.$el); },
            beforeMount() { console.log('beforeMount'); },
            mounted() {
                // 【常用】挂载结束，dom已经存在
                console.log('mounted ' + this.$el);
                setTimeout(() => {
                    this.testData = '我被修改了';
                }, 2000);
            },
            beforeUpdate() { console.log('beforeUpdate'); },
            updated() { console.log('updated'); }
        });
    </script>
</body>

</html>